$(function () {
  // 加载时隐藏
  $(".container-fluid").hide()
  // 返回上一页
  $("#toBack").click(function () {
    history.back(-1)
  })
  // 设置导航栏文字
  function setNavigation() {
    if ($.getUrlParam("from") == 1) {
      $("#toBack").text("会员单位")
    } else if ($.getUrlParam("from") == 2) {
      $("#toBack").text("首页")
    } else {
      $("#toBack").hide()
      $(".main-nav .line").hide()
    }
  }
  // 获取会员单位详情
  function getEnterprise() {
    $.ajax({
      method: 'GET',
      url: adminPath + '/api/wdsxh/member/detail',
      data: {
        type: 2,
        id: $.getUrlParam("id")
      },
      success: function (res) {
        $(".container-fluid").show()
        if (res.code == 1) {
          var indicatorsHtml = ""
          var innerHtml = ""
          for (var i in res.data.company_images) {
            indicatorsHtml += `<li data-target="#carouselExampleIndicators" data-slide-to="${i}" ${i == 0 ? 'class="active"' : ''}></li>`
            innerHtml += `<div class="carousel-item ${i == 0 ? 'active' : ''}"><img src="${res.data.company_images[i]}" class="d-block w-100"></div>`
          }
          $("#carouselExampleIndicators .carousel-indicators").html(indicatorsHtml)
          $("#carouselExampleIndicators .carousel-inner").html(innerHtml)
          if(!res.data.company_images) $("#carouselExampleIndicators").hide()
          $(".content-info .info-logo img").attr("src", res.data.company_logo)
          $(".content-info .info-logo img").attr("alt", res.data.company_name)
          $(".content-info .info-cont .name").text(res.data.company_name)
          $(".content-info .info-cont .post").text(res.data.level.name)
          $(".content-info .info-cont .address").text(res.data.company_address)
          var tagHtml = ""
          for (var i in res.data.label) {
            tagHtml += `<div class="tag-item">${res.data.label[i]}</div>`
          }
          $(".content-info .info-cont .tag").html(tagHtml)
          $(".content-introduce .introduce-cont").html(res.data.company_introduce)
        } else {
          console.error(res.msg)
        }
      },
    })
  }
  // 调用方法
  setNavigation()
  getEnterprise()
})